import {
  q as n,
  ap as ue,
  X as W,
  f as de,
  H as ce,
  av as N,
  aw as pe,
  k as s,
  m as o,
  l as d,
  ax as fe,
  as as c,
  az as he,
  at as I
} from "./index-b50e6ef9.js";
import { k as ge, j as Y } from "./activity-9dc68ac4.js";
function be(J) {
  const D = n([]),
    F = n([]),
    U = n({}),
    f = n(!0),
    h = n(1),
    g = n(10),
    _ = n(1),
    x = n(10),
    a = n([]),
    m = n({}),
    v = n();
  n("");
  const z = n(),
    p = n(""),
    S = n(),
    A = ue("reload"),
    C = W({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    B = W({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [5, 10, 20],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    E = W({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [5, 10, 20],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    L = W({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    M = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      { label: "剩余次数", prop: "draw_num", minWidth: 120 },
      { label: "获得字符", prop: "obtain_char", minWidth: 100 },
      { label: "剩余字符", prop: "residue_char", minWidth: 100 },
      {
        label: "状态",
        prop: "type",
        minWidth: 150,
        formatter: ({ type: e }) => {
          if (e == 0)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("未集齐")] }
            );
          if (e == 1)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [o("已集齐")] }
            );
        }
      },
      {
        label: "类型",
        prop: "activity",
        minWidth: 150,
        formatter: ({ activity: e }) => {
          if (e == 1) return s("span", null, [o("元旦")]);
          if (e == 2) return s("span", null, [o("春节")]);
        }
      },
      { label: "创建时间", minWidth: 180, prop: "create_time" },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    R = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "phone", minWidth: 120 },
      { label: "收件人姓名", prop: "name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: t }) => {
          if (e == 1)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("待发货")] }
            );
          if (e == 2)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("待自提")] }
            );
          if (e == 7)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("在线支付积分不足")] }
            );
          if (e == 8)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("奖励发放中")] }
            );
          if (e == 9)
            return s(
              d("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [o("待发放奖励")] }
            );
          if (e == 3 && t != "自提")
            return s(
              d("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [o("已快递")] }
            );
          if (e == 3 && t == "自提")
            return s(
              d("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [o("已自提")] }
            );
        }
      },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) =>
          fe(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    O = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "姓名", prop: "user_name", minWidth: 150 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      { label: "本次抽取字符", prop: "draw_char", minWidth: 100 },
      { label: "创建时间", minWidth: 180, prop: "create_time" }
    ],
    T = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "姓名", prop: "user_name", minWidth: 150 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      { label: "助力姓名", prop: "draw_user_name", minWidth: 100 },
      { label: "助力手机号", prop: "draw_user_phone", minWidth: 100 },
      { label: "创建时间", minWidth: 180, prop: "create_time" }
    ],
    H = de(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function y(e, t) {
    (m.value = e), (v.value = t);
    const u = { page: _.value, pagesize: x.value, user_id: e.user_id, type: t },
      b = JSON.stringify(u),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(b)) },
      l = await ge(i);
    l.code == 200 &&
      ((F.value = l.data.data),
      (B.total = l.data.total),
      (E.total = l.data.total));
  }
  async function j(e) {
    he(e);
  }
  async function q(e) {
    const t = { id: e.id },
      u = JSON.stringify(t),
      r = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(u)) },
      i = await questionDelete(r);
    i.code == 200
      ? (I("删除成功", { type: "success" }), A())
      : I(i.msg, { type: "error" });
  }
  function $() {}
  function V(e) {
    (g.value = e), w(void 0, e);
  }
  function X(e) {
    (h.value = e), w(e, void 0);
  }
  function G(e) {}
  function K(e) {
    (x.value = e), y(m.value, v.value);
  }
  function Q(e) {
    (x.value = e), y(m.value, v.value);
  }
  function Z(e) {
    (_.value = e), y(m.value, v.value);
  }
  function P(e) {
    (_.value = e), y(m.value, v.value);
  }
  function ee(e) {}
  function te(e) {
    (L.text = `正在加载第${e}页...`),
      (f.value = !0),
      N(600).then(() => {
        f.value = !1;
      });
  }
  async function ae(e, t, u = [], b, r, i) {
    (a.value = []),
      u.map(re => {
        const se = re,
          oe = new Date(se);
        a.value.push(
          oe.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (f.value = !0),
      (z.value = e),
      (p.value = r),
      (S.value = i);
    let l = {};
    i && i == 1
      ? (l = {
          page: h.value,
          pagesize: g.value,
          user_phone: t || void 0,
          start: a.value[0],
          end: a.value[1],
          activity: r || void 0,
          typeYes: 1
        })
      : i && i == 2
      ? (l = {
          page: h.value,
          pagesize: g.value,
          user_phone: t || void 0,
          start: a.value[0],
          end: a.value[1],
          activity: r || void 0,
          typeNo: 1
        })
      : (l = {
          page: h.value,
          pagesize: g.value,
          user_phone: t || void 0,
          start: a.value[0],
          end: a.value[1],
          activity: r || void 0
        });
    const le = JSON.stringify(l),
      ie = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(le)) },
      { data: k } = await Y(ie);
    (D.value = k.data),
      (C.total = k.total),
      setTimeout(() => {
        f.value = !1;
      }, 500);
  }
  async function w(e = h.value, t = g.value) {
    let u = {};
    S.value == 1
      ? (u = {
          page: e,
          pagesize: t,
          start: a.value[0],
          end: a.value[1],
          activity: p.value ? p.value : void 0,
          typeYes: 1
        })
      : S.value == 2
      ? (u = {
          page: e,
          pagesize: t,
          start: a.value[0],
          end: a.value[1],
          activity: p.value ? p.value : void 0,
          typeNo: 1
        })
      : (u = {
          page: e,
          pagesize: t,
          start: a.value[0],
          end: a.value[1],
          activity: p.value ? p.value : void 0
        });
    const b = JSON.stringify(u),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(b)) },
      l = await Y(i);
    l.code === 200
      ? ((D.value = l.data.data),
        (C.total = l.data.total),
        setTimeout(() => {
          f.value = !1;
        }, 500))
      : I(l.msg, { type: "error" });
  }
  const ne = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ce(() => {
      N().then(() => {
        const { setWatermark: e } = pe(J.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        w();
    }),
    {
      loading: f,
      columns: M,
      dataList: D,
      userColumns: O,
      userColumns1: T,
      pagination: C,
      buttonClass: H,
      userDatilList: F,
      orderInfo: U,
      columnsTable: R,
      count: h,
      pageCount: g,
      formattedDate: a,
      typeCount: z,
      paginationStore: B,
      paginationStore1: E,
      handleLookUserDatil: y,
      handleSizeChangeStore: K,
      handleSizeChangeStore1: Q,
      handleCurrentChangeStore: Z,
      handleCurrentChangeStore1: P,
      handleSelectionChangeStore: ee,
      onSearch: ae,
      resetForm: ne,
      handleaddUser: $,
      handleUpdate: j,
      handleDelete: q,
      handleSizeChange: V,
      handleCurrentChange: X,
      handleSelectionChange: G,
      onCurrentChange: te
    }
  );
}
export { be as useRole };
